package nc.bs.pp.ask;

import nc.vo.pp.ask.PriceauditBVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.VOStatus;
import nc.vo.scm.pub.smart.ObjectUtils;

public class AskBillBO {

	public void reWriteNum(PriceauditBVO[] itemVOS, boolean flag)
			throws BusinessException {

		if (itemVOS == null || itemVOS.length == 0)
			return;
		
		try {
			PriceauditBVO[] itemvos = (PriceauditBVO[]) ObjectUtils.serializableClone(itemVOS);
			ReWriteBackTool.setVsourcebilltype("cupsourcebilltype");
			ReWriteBackTool.setVsourcebillid("cupsourcebillid");
			ReWriteBackTool.setVsourcebillrowid("cupsourcebillrowid");
			
			if (flag) {
				ReWriteBackTool.writeBack(itemvos, "po_askbill_b","caskbill_bid", new String[] { "nnum" },new String[] { "vdef20" },new String[] { "nasknum" }, true);
			} else {
				for (int i = 0; i < itemvos.length; i++) {
					itemvos[i].setStatus(VOStatus.DELETED);
				}
				ReWriteBackTool.writeBack(itemvos, "po_askbill_b","caskbill_bid", new String[] { "nnum" },new String[] { "vdef20" },new String[] { "nasknum" }, true);
			}
		} catch (Exception e) {
			if (e instanceof BusinessException)
				throw (BusinessException) e;
			else
				throw new BusinessException(e.getMessage());
		}
	}
}
